package com.by.toolkit.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum FlagEnum {

    NO(0, "否"),
    YES(1, "是");

    private Integer code;
    private String desc;

    public static Integer resolve(boolean yesOrNo) {
        return yesOrNo ? FlagEnum.YES.getCode() : FlagEnum.NO.getCode();
    }

    public static String resolve2Desc(boolean yesOrNo) {
        return yesOrNo ? FlagEnum.YES.getDesc() : FlagEnum.NO.getDesc();
    }

    public static boolean resolve(Integer value) {
        return FlagEnum.YES.getCode().equals(value);
    }

    public static boolean yes(Integer value) {
        return FlagEnum.YES.getCode().equals(value);
    }

    public static boolean no(Integer value) {
        return !yes(value);
    }

    public static Integer negation(Integer value) {
        return yes(value) ? FlagEnum.NO.getCode() : FlagEnum.YES.getCode();
    }

    public static final String NO_STR = "0";

    public static final String YES_STR = "1";

}
